<extend name="Include:Layout"/>
<block name="title">签到</block>
<block name="style">
<style>
.weui_content {padding-left: 15px;padding-right: 15px;background-color:#fff !important;margin-bottom:10px;}
.weui_select {height:30px;line-height:30px;}</style>
</block>

<block name="main">
	<div class="weui_tab">
		<div class="weui_tab_bd container" id="container">
			<form>
			<div class="weui_cells weui_cells_form">
			  <div class="weui_cell">
			    <div class="weui_cell_hd"><label class="weui_label">日期选择</label></div>
			    <div class="weui_cell_bd weui_cell_primary">
			      <input class="weui_input" id="my-input" type="text" name="title" value="{$info.title}" />
			    </div>
			  </div>
			</div>
			<php>
				$dao = explode(',',$info['dao']);
				$weidao = explode(',',$info['weidao']);
				$qingjia = explode(',',$info['qingjia']);
			</php>
			<div class="weui_cells_title">学生</div>
			<div class="weui_cells weui_cells_form">
			  <volist name="students" id="vo">
			  <php>
	  			$d = 0;
	  			if(in_array($vo['id'],$dao)){
	  				$d = 1;
	  			}
	  			if(in_array($vo['id'],$weidao)){
	  				$d = 2;
	  			}
	  			if(in_array($vo['id'],$qingjia)){
	  				$d = 3;
	  			}
	  		</php>
			  <div class="weui_cell">
			    <div class="weui_cell_hd"><label class="weui_label">{$vo.student}</label></div>
			    <div class="weui_cell_bd weui_cell_primary">
			    	<label><input type="radio" name="users[{$vo.id}]" value="1" <if condition="$d eq 1">checked</if>/>已到</label>
			    	<label style="margin-left:20px;"><input type="radio" name="users[{$vo.id}]" value="3" <if condition="$d eq 3">checked</if>/>请假</label>
			    </div>
			  </div>
			  </volist>
			</div>
			<div style="padding:15px;">
				<input type="hidden" name="id" value="{$info['id']}"/>
				<input type="hidden" name="lid" value="{$lid}"/>
				<input type="hidden" name="uid" value="{$uid}"/>
				<button class="weui_btn weui_btn_primary btncheckorder">提交</button>
			</div>
			</form>
	    </div>
    </div>
</block>

<block name="script">
<script>
$(function(){
	var myDate = getNowFormatDate();
	$("#my-input").calendar({value: [myDate]});
})

function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
    return currentdate;
}

$(".btncheckorder").click(function(){
	var thisBtn = $(this);
	if(thisBtn.attr('disabled') == 'disabled') {
        return;
	}
	var title=$("input[name=title]").val();
	if(title == ''){
		$.alert("时间不能为空","");
		return false;
	}
	$.showLoading();
	thisBtn.attr('disabled', 'disabled');
	$.post('/Api/Student/savesign.html',$("form").serialize(),function(data){
		$.hideLoading();
		//console.log(data);
		thisBtn.removeAttr('disabled');
		if(data.status){
			location.href="/home/my/signlist/lid/{$lid}.html";
		}else{
			$.alert(data.info,"",function(){
				location.href="/home/my/signlist/lid/{$lid}.html";
			});
			return false;
		}
	});
	
})
</script>
</block>